package com.rykj.base;


import com.rykj.util.CommonUtil;

/**
 * Description: author: zhangsan on 17/1/3 下午3:18.
 */

public abstract class BasePresenter<T extends MvpView> implements Presenter<T> {

    protected final String TAG = this.getClass().getName();

    protected T mvpView;

    // protected Class<T> mvpClazz;
    // protected T emptyService;
    protected T checkNone() {
        return CommonUtil.checkNotNull(mvpView);
    }

    @Override
    public void attachView(T mvpView) {
        this.mvpView = mvpView;
        //  mvpClazz= (Class <T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
        //  emptyService=creatEmptyService();
    }

    @Override
    public void detachView() {
        mvpView = null;
    }

    //public T creatEmptyService(){
    //    return (T) Proxy.newProxyInstance(mvpClazz.getClassLoader(), new Class<?>[] { mvpClazz },
    //            new InvocationHandler() {
    //                @Override
    //                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    //                    LogX.e("BasePresenter","service null");
    //                    return mvpClazz.newInstance();
    //                }
    //            });
    //}
}
